
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import ui.ClacGui;
import ui.Terminal;


public class AltaRica {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) {
		
		int ui = 1;
		
        System.out.println("Clac Version 0.1\n");
		
		if (args.length == 1) {			
			if ((new File(args[0])).exists()) {
				try {
					FileInputStream script =  new FileInputStream(args[0]);
					boolean cont = Terminal.Launch(script);
					script.close();
					if (cont == false)
						return;
				} catch (FileNotFoundException e) {
					System.out.println("Unable to open the file: " + args[0]);
					return;
				} catch (IOException e) {
					System.out.println("Error: unable to close the file: " + args[0]);
				}
			}
		}
		
		if (ui == 1) {
			Terminal.Launch();
		} else if (ui == 2) {
			ClacGui.launchClacGui();
		}
		
	}

}
